package com.atyang.controller;

import com.atyang.annotation.RedisLock;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@RestController
public class HelloController {

    @RequestMapping("/hello")
    public String hello(){
        return "Hello World";
    }


    /**
     * 测试分布式定时任务
     */
    @RedisLock(lockPrefix = "hello",lockKey = "world")
    @Scheduled(cron = "0,30 * * * * ?")
    public void testTiming(){
        System.out.println("每隔30秒定时任务测试,当前时间为:" +
                new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒").format(new Date()));
    }

}
